home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / clipper / ks94an.zip / ARR2STR.HDR < prev    next >
Text File  |  1994-04-25  |  2KB  |  83 lines

  1. /******************************************************************************
  2.                  The Klipper Library, for CA-Clipper 5.x
  3.         Copyright (c), 1994, Wallace Information Systems Engineering
  4.  
  5. FUNCTION:
  6.  
  7. _Array2Str(xArray) --> cString
  8.  
  9. PARAMETERS:
  10.  
  11. xArray: Array containing elements of types C, N, D, L, or NIL
  12.  
  13. SHORT:
  14.  
  15. Convert an array to a single character string.
  16.  
  17. DESCRIPTION:
  18.  
  19. _Array2Str() stores and array (either single or multiple dimension) in
  20. a string formatted such that _Str2Array() can recreate it.
  21.  
  22. It can be used in conjunction with Var2File() to store arrays (again,
  23. single or multiple dimension) to disk files.
  24.  
  25. The resulting string is only useful and meaningful to _Str2Array() so any
  26. use of it without this other function is highly suspect.
  27.  
  28. NOTE:
  29.  
  30. _Array2Str() will ignore any element that is not character, numeric,
  31. date, logical or another array of the same!!
  32.  
  33. Code blocks are right out!  Same for Memos and "objects."
  34.  
  35. Any attempt to use _Array2Str() with these unsupported data types will
  36. render unpredictable results.
  37.  
  38. EXAMPLE:
  39.  
  40. t = {'a','b',{'1','2','3'},'d')
  41.  
  42. astr = _Array2Str(t)
  43.  
  44. Result: aStr is a string containing the entire array.  It can now be restored
  45. to an array with "t = _Str2Array(astr)", or it can be written to a disk file
  46. via _Var2File(astr).
  47.  
  48.  
  49. To completely store and restore an array to and from disk:
  50.  
  51. // going in...
  52. aArray = {'a','b',{'1','2','3'},'d')
  53.  
  54. aStrArray = _Array2Str(aArray)
  55.  
  56. _Var2File(aStrArray,"FILE.EXT")
  57.  
  58. // coming out...
  59. t = {}
  60.  
  61. aStrArray = _File2Var("FILE.EXT")
  62.  
  63. t = _Str2Array(aStrArray)
  64.  
  65. // or, simplified:
  66.  
  67. aArray1 = {'a','b',{'1','2','3'},'d')
  68.  
  69. _Var2File(_Array2Str(aArray),"FILE.EXT")
  70.  
  71. aArray2 = _File2Var("FILE.EXT")
  72.  
  73. // or, a one-liner:
  74.  
  75. aArray2 = _Str2Array(_File2Var(_Var2File(_Array2Str(aArray1),"FILE.EXT")))
  76.  
  77. which essentially copies aArray1 to aArray2 via a disk file.
  78.  
  79. This is possible because _Var2File() returns the name of the file the
  80. variable was stored in.  (See _VAR2FILE()).
  81.  
  82. ******************************************************************************/
  83.